Skip to content

fix(driver-sql): a plain index MySQL refuses to key no longer skips the object's remaining boot steps - #38225

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-35862-mysql-text-index
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-35862-mysql-text-index

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Part of #35862 — this lands the card's half (B), the bounded one it orders first. Half (A) stays open on the card: converging an old MySQL TEXT column to its declared varchar(n), then the inbox index itself, which this dispatch excluded (it belongs to the other half of #35530).
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:使用 MySQL 的部署里,某个对象声明的普通(非唯一)索引如果落在旧的长文本列上,MySQL 会拒建;以前这会让该对象每次启动都跳过后续的数据修复步骤并报"同步失败",现在只记一条错误日志、其余步骤照常跑完。PostgreSQL 与 SQLite 用户无感。
  • 为什么做:这是收件箱铃铛提速(给消息表加按用户和时间的索引)的前置一半,先保证这类索引被拒时不再连带丢掉别的启动步骤。
  • 出错会怎样:被拒的索引依旧不建、不做替代,日志照常报出并给出手工改列的办法;本改动可以直接撤回,撤回后回到原先"抛错并跳过后续步骤"的行为。
  • 要你做什么:另一半(把旧文本列收敛成定长列,再上收件箱索引)走哪条路需要你定,见下方 Acceptance notes 第一条。

What changes

  • syncDeclaredIndexes (packages/drivers/driver-sql/src/sql-driver-schema-sync.ts): when MySQL refuses to key a PLAIN index (ER_BLOB_KEY_WITHOUT_LENGTH or ER_TOO_LONG_KEY, the codes explainUnkeyableTextColumn recognises), the refusal is still logged once at error through logDurabilityFailure with the same field-level remedy, and the loop now continues instead of throwing. The index is still not created and still not substituted: no prefix index, no hash shadow (the existing scope limit for non-unique indexes).
  • What the throw used to cost, measured on live MySQL 8.0.46 before the fix: initObjects rejected for the object, so every index declared after the refused one was never attempted, and retireIndexesNamedForOldKeys, reconcileAndWarnDrift, the four canonical backfills and migrateMysqlDatetimeColumns / migrateMysqlTimeColumns never ran for that table, on every boot.
  • Unchanged on purpose: a UNIQUE index that the hash-shadow route could not carry still throws (the card's CONTROL). PostgreSQL and SQLite never raise these codes, so their path is byte-identical.
  • Why the fix sits in the producer and not in a catch in initObjects / syncTableIndexes: the throw is the defect; a catch further up would still lose every index after the refused one in the same loop, and would also swallow the UNIQUE case the card keeps.

Tests

  • New sql-driver-35862-refused-plain-index-boot-steps.test.ts:
    • everywhere (SQLite): the MySQL refusal faked at knex.schema.alterTable with MySQL's own error shape, for both codes. Pins: one error line naming the object and the index; the refused index absent; the index declared after it built; every later boot step (8 named) called for the table; the drift report's warn line present. CONTROL: the same refusal on a UNIQUE index still rejects with code: 'ER_BLOB_KEY_WITHOUT_LENGTH' and the named refusal.
    • every dialect cell (SQLite, live PostgreSQL, live MySQL): the real upgrade, a TEXT user_id from the release before the bound, then the release that declares maxLength: 255 and a plain (user_id, created_at) index plus a seen_at index. On MySQL: the column is still TEXT (the premise), the plain index is absent with no shadow column, one error line, the seen_at index built, and a legacy TIMESTAMP seen_at widened to datetime(3) (the last step initObjects runs). CONTROL on PostgreSQL and SQLite: the index is built directly, no error line.
    • live MySQL CONTROL: a UNIQUE index over a maxLength: 1024 text column is still carried on a hash shadow (whole key part, SUB_PART null, NON_UNIQUE 0).
  • Rewritten, not deleted: three live MySQL pins asserted initObjects REJECTS for a non-unique unkeyable index (sql-driver-11627-hash-shadow-key.test.ts one, sql-driver-keyed-text-mysql.test.ts two). They pinned exactly the throw this change removes; they now read the same named refusal from the error channel and keep their negative half (no index keys the column, no shadow column).
  • In CI the live cells run in Temporal Conformance (live PG + MySQL), step "Run driver-sql suite against both live servers" (it runs this whole package with OS_TEST_MYSQL_URL and OS_TEST_POSTGRES_URL set and OS_EXPECT_LIVE_DIALECT_MATRIX=1). The SQLite layer also runs in Test Core.

Acceptance notes

  • Fork left for the maintainer, half (A): the card's own Expected section asks for a keyed TEXT column to converge to its declared varchar(n) on MySQL, "either schema sync or an os migrate arm", refusing with the offending rows named when a stored value is longer than n. That choice is open, and neither alternative named in the dispatch fits: a hash shadow is ruled out for non-unique indexes by the existing scope limit (a digest serves no lookup), and a prefix index is a valid access path for a plain index but is not what the card asks for. No code for (A) is in this PR.
  • The refusal line explainUnkeyableTextColumn writes ends with "so any uniqueness it declared is currently unenforced" and a sentence about UNIQUE prefix indexes; on a plain index both are true but beside the point. Left as is: the line is shared with the UNIQUE path.
  • After the refusal the drift report warns that the index is missing and says to run "os migrate apply" to create it; on MySQL that apply meets the same refusal and reports the index as not applied (the create op checks presence). Existing wording, not changed here.
  • SqlDriver#syncDeclaredIndexes's docblock in sql-driver.ts lists the dispositions; a bullet for this one would push the facade over its line ceiling (check:facade-delegation-only, 10071 lines, 0 left), so the disposition is documented at the body in sql-driver-schema-sync.ts instead.

Verification

Read first, by risk:

  1. packages/drivers/driver-sql/src/sql-driver-schema-sync.ts, the new if (!unique) arm after this.logDurabilityFailure(unkeyable, msg): the only behaviour change.
  2. packages/drivers/driver-sql/src/sql-driver-35862-refused-plain-index-boot-steps.test.ts, the refuseIndexes fake: it decides the refusal from the index the alterTable callback declares, and passes everything else to the real knex.
  3. packages/drivers/driver-sql/src/sql-driver-keyed-text-mysql.test.ts, the two rewritten pins.

Two-minute check: pnpm --filter @objectstack/driver-sql exec vitest run sql-driver-35862 prints Tests 4 passed | 3 skipped (7) with no server (the 3 skipped are the live PostgreSQL and MySQL cells); with OS_TEST_MYSQL_URL and OS_TEST_POSTGRES_URL set it prints Tests 7 passed (7).

Readings, all at head f1c4549df3, on local MySQL 8.0.46 (server zone +08:00) and PostgreSQL 16 (Asia/Shanghai), process TZ=America/New_York, OS_EXPECT_LIVE_DIALECT_MATRIX=1:

The three touched files on live MySQL + PostgreSQL: 26/26

vitest run sql-driver-35862 sql-driver-11627-hash-shadow-key sql-driver-keyed-text-mysql: Test Files 3 passed (3), Tests 26 passed (26).

Ablation: the fix removed, 6 red and every CONTROL green

scripts/ablation-replace.mjs replaced the anchor if (!unique) { with if (false) { (anchor 1 to 0, blob 3fbbf2dfc9e7 to c0aaa9b00fb7) and ran the same three files: Tests 6 failed | 20 passed (26). Red: both faked refusals, the live MySQL upgrade (it rejected with ER_BLOB_KEY_WITHOUT_LENGTH on idx_os35862_inbox_user_id_created_at, which is the card's premise, measured), and the three rewritten pins. Green: the UNIQUE CONTROL, the PostgreSQL and SQLite upgrade CONTROLs, the live hash-shadow CONTROL. Restored: blob equals HEAD (3fbbf2dfc9e7), git diff HEAD empty.

Whole driver-sql suite: 7052 passed, 1 failed, both failing files environmental

pnpm --filter @objectstack/driver-sql exec vitest run --maxWorkers=2: Test Files 2 failed | 283 passed | 1 skipped (286), Tests 1 failed | 7052 passed | 12 skipped (7065). The two files: sql-driver-37095-pgvector-extension (the local PostgreSQL has no pgvector extension; CI uses the pgvector image) and sql-driver-11565-row-byte-budget "reports InnoDB page-limit refusals" (fails identically with the fix ablated, so it is this local server, not this diff). pnpm --filter @objectstack/driver-sql typecheck: exit 0.

Derived gate families: 67 exit 0, 2 not measured

dispatch-gates.mjs --commands (5 paths vs merge base 7605e0c) derived 69; all run; --ran reconciliation: 67 run, 2 NOT MEASURED. The two are check:dual-build-cjs-loads and check:lean-entry-closure, both exit 3 PREREQUISITE NOT MET (they read built output of the whole workspace, not built here); CI runs them.


Generated by Claude Code

…bject's remaining boot steps

Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8
Co-authored-by: Claude <noreply@anthropic.com>
…e, live MySQL and PostgreSQL

Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8
Co-authored-by: Claude <noreply@anthropic.com>
…isposition is documented at the body

Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json f19350b410df08db604881848b2c370047a114f2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 6f7e8242f4ad28dc7152cc844db172d1bef2989d — the merge of head 0da725c4674955b5e266fe9778fc9928f9af0f3b into base f19350b410df08db604881848b2c370047a114f2, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 6f7e8242f4ad28dc7152cc844db172d1bef2989d && git checkout 6f7e8242f4ad28dc7152cc844db172d1bef2989d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f19350b410df08db604881848b2c370047a114f2 0da725c4674955b5e266fe9778fc9928f9af0f3b && git checkout -B drift-repro f19350b410df08db604881848b2c370047a114f2 && git merge --no-ff 0da725c4674955b5e266fe9778fc9928f9af0f3b

node scripts/docs-audit/affected-docs.mjs --json f19350b410df08db604881848b2c370047a114f2

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

Seat reading, head f1c4549d: Test Core (9/10) and its aggregate Test Core are red on one test outside this PR. @objectstack/plugin-approvals → src/stranded-request-inspection.test.ts → "an older strand outside the newest window is reached by the cursor within a bounded number of sweeps" failed with Error: Test timed out in 5000ms. That is the load-sensitive flake already filed as #38223. This PR touches only packages/drivers/driver-sql/** and its changeset, and nothing it changes reaches plugin-approvals.

Judged a flake ⇒ the seat re-runs the failed jobs of run 46125233126 once through rerun-failed.mjs. A second failure counts as real.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

L1: ACCEPT · head 0da725c467 · 2026-11-28T11:05Z · card #35862

Seat checks

  1. Shape: draft on main, mergeable_state clean. The first line is Part of #35862, which is right: this lands the card's half (B), the bounded one it orders first. Clause-②: no · Metadata-protocol: none. The card keeps pm:dispatched for half (A) (landing rule B).
  2. Half (A): how a keyed TEXT column already on MySQL reaches its declared varchar(n). It is a design fork reported in the dev's open_questions (os-dev-report 7236521379). The fable-tier analysis is done (A1′ recommended: a migration-door op whose category is set by a data pre-flight). It is before the maintainer for a ruling, recorded on the card when ruled.
  3. Read by the seat: sql-driver-schema-sync.ts syncDeclaredIndexes.
    • A PLAIN index that MySQL refuses to key (ER_BLOB_KEY_WITHOUT_LENGTH / ER_TOO_LONG_KEY) is logged once at error on the durability channel with the same remedy, and the loop continues. Later indexes and the object's remaining boot steps now run.
    • A UNIQUE index the hash-shadow route could not carry still throws (the card's CONTROL).
    • The index is still not created and not substituted. The drift report still lists it as missing.
    • The changeset's FROM/TO states exactly that, sentence by sentence. PostgreSQL and SQLite are unchanged.
  4. Evidence: premise measured on live MySQL 8.0.46. With the fix ablated, the inbox-shaped upgrade rejects initObjects with ER_BLOB_KEY_WITHOUT_LENGTH.
  5. CI history: Test Core (9/10) went red once at f1c4549d on flake flake: plugin-approvals stranded-request-inspection.test.ts "an older strand outside the newest window is reached by the cursor" times out at 5 s under CI load (2 independent merge-queue hits) #38223 (plugin-approvals, Test timed out in 5000ms), outside this diff. The seat re-ran it once (reason recorded in comment 7237657772) and it went green. flake: plugin-approvals stranded-request-inspection.test.ts "an older strand outside the newest window is reached by the cursor" times out at 5 s under CI load (2 independent merge-queue hits) #38223's fix (test(plugin-approvals): seed the past-500-decided stranded-scan cases in batches, not 1200 serial inserts #38235) has since merged.
  6. Gates at this head (main merged in through the relay): 37 success · 16 expected skip · 0 failed · 0 pending. NOT governed (+437/−16). K = 5 < 15. L2 not owed: Clause-②: no, no schema or governed path, no narrowing arm. A refusal that throws becomes a logged skip, and nothing a valid model writes is refused.

Landing: non-governed, ≤3000 lines. The seat lands it through the ordinary queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 28, 2026 11:06
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 46138308401 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Dogfood Regression Gate (3/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/expression-conformance.test.ts > ADR-0058 D7 — expression surface conformance ledger > is a sound conformance ledger + ratchet (ADR-0060 checkLedger)
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: UNCLASSIFIED surface — add a ledger row (ADR-0060): data/object.zod.ts:ObjectSchemaBase.uiReadonlyWhen: expected [ Array(1) ] to deeply equal []
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 23 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants